package com.v1.video.adapter;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.iss.view.common.ToastAlone;
import com.v1.video.Constant;
import com.v1.video.R;
import com.v1.video.activity.OtherPersonHomeActivity;
import com.v1.video.domain.LoginInfo;
import com.v1.video.domain.ResultInfoEntity;
import com.v1.video.domain.SetHead;
import com.v1.video.domain.UserInfo4_4;
import com.v1.video.domain.StarPeopleDetailEntity.StarFans;
import com.v1.video.httpmanager.ParamList;
import com.v1.video.httpmanager.ParamList.Parameter;
import com.v1.video.httpmanager.RequestManager;
import com.v1.video.httpmanager.RequestManager.OnResponseListener;
import com.v1.video.util.Helper;
import com.v1.video.util.Logger;

public class AdapterStarFans extends BaseAdapter {

	private final String TAG = "MyLoginVideoAdapter";
	private LayoutInflater mLayoutInflater;
	private Context mContext;
	private List<StarFans> mLstData;
	public static int count = 0;
	private int flag = 0;
	public AdapterStarFans(Context context,int flag) {
		mContext = context;
		mLayoutInflater = LayoutInflater.from(context);
		mLstData = new ArrayList<StarFans>();
		this.flag = flag;
	}

	public List<StarFans> getLstData() {
		return mLstData;
	}

	public void setLstData(List<StarFans> mLstData) {
		if (mLstData != null && mLstData.size() > 0) {
			this.mLstData = mLstData;
			this.notifyDataSetChanged();
		}
	}
	
	public void setAddLstData(List<StarFans> mLstData) {
		if (mLstData != null && mLstData.size() > 0) {
			this.mLstData.addAll(mLstData);
			this.notifyDataSetChanged();
		}
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return mLstData.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return mLstData.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		final Holder holder;
		if (convertView == null) {
			convertView = mLayoutInflater.inflate(
					R.layout.item_person_info, null);
			
			holder = new Holder();
			holder.imageHead = (ImageView) convertView.findViewById(R.id.iv_user_img);
			holder.imgLevel = (ImageView) convertView.findViewById(R.id.iv_user_level);
			holder.nickName = (TextView) convertView.findViewById(R.id.tv_nickname);
			holder.userDes = (TextView) convertView.findViewById(R.id.paike_detail_cicle_fromname);
			holder.txtSubscribe = (TextView) convertView.findViewById(R.id.tv_attention);
			holder.layAttention = (LinearLayout)convertView.findViewById(R.id.lay_attention);
			convertView.setTag(holder);
		} else {
			holder = (Holder) convertView.getTag();
		}
		final StarFans info = mLstData.get(position);
		SetHead setHead = new SetHead();
		setHead.setHead(info.getUsr_avatar(), "", holder.imageHead);
		if(info.getIsauth().equals("1")){
			holder.imgLevel.setVisibility(View.VISIBLE);
		}else{
			holder.imgLevel.setVisibility(View.GONE);
		}
		holder.nickName.setText(info.getUsr_nickname());
		holder.userDes.setText(info.getAutograph());
		
		holder.layAttention.setVisibility(View.GONE);
		
		return convertView;
	}

	private class Holder {
		public RelativeLayout layItem;
		public ImageView imageHead;
		public ImageView imgLevel;
		public TextView nickName;
		public TextView userDes;
		public TextView txtSubscribe;
		public LinearLayout layAttention;
	}
	
	public void gotoOtherPersonHome(String userId,String nickName,String userSex,String isCertification,String userHead,String userDesc,String focousType){
    	Intent intent = new Intent();
    	intent.setClass(mContext, OtherPersonHomeActivity.class);
    	intent.putExtra("userId", userId);
    	intent.putExtra("nickName", nickName);
    	intent.putExtra("userSex", userSex);
    	intent.putExtra("isCertification", isCertification);
    	intent.putExtra("userHead", userHead);
    	intent.putExtra("userDesc", userDesc);
    	intent.putExtra("focousType", focousType);
    	mContext.startActivity(intent);
    }
	
	
}
